import { socialData } from './_localData.js';
import { AjaxRequest } from '../utils/request.js';
import { SocialRenderFn } from '../utils/render.js';
import { initEvent } from '../utils/init.js';

window.onload = initEvent();

// 社会招聘-section1 轮播图分组
let carouselGroupSocial_s1 = [];
// 社会招聘-section2 轮播图分组
let carouselGroupSocial_s2 = [];

(async function getData() {
    const a = await AjaxRequest('carouselGroup/get', 105, 'carouselGroupId');
    carouselGroupSocial_s1 = [...a.w_carousels];
    
    const b = await AjaxRequest('carouselGroup/get', 106, 'carouselGroupId');
    carouselGroupSocial_s2 = [...b.w_carousels];

    load();
})()

function load() {
    const questionArea = document.querySelector('.questionArea');
    const reminder = document.querySelector('.reminder');

    // section1
    let questionData = [];
    carouselGroupSocial_s1.forEach((item,index)=>{
        questionData.push({...socialData.questionArea[index],...item});
    })
    const questionRender = new SocialRenderFn(questionArea,questionData);
    questionRender.questionAreaFn();

    // section2
    const reminderRender = new SocialRenderFn(reminder,carouselGroupSocial_s2);
    reminderRender.reminderFn();
}